import { IFeidaoAiWeappPage } from '@dfeidao/atom-wxapp/interfaces';
import show_loading from '@dfeidao/atom-wxapp/api/interaction/show-loading';
import show_nav_bar_loading from '@dfeidao/atom-wxapp/api/interaction/show-nav-bar-loading';
import hide_loading from '@dfeidao/atom-wxapp/api/interaction/hide-loading';
import hide_nav_bar_loading from '@dfeidao/atom-wxapp/api/interaction/hide-nav-bar-loading';
import nodejs from '@dfeidao/atom-wxapp/msg/nodejs';
import show_modal from '@dfeidao/atom-wxapp/api/interaction/show-modal';
// import redirect_to from '@feidao/web/atom/wx/app/api/navigation/redirect-to';
import navigate_back from '@dfeidao/atom-wxapp/api/navigation/navigate-back';
import render from '@dfeidao/atom-wxapp/render/render';
import set_local from '@dfeidao/atom-wxapp/local/set';


export default async function a001(fd: IFeidaoAiWeappPage, e: {
	detail: {
		value: string;
	}
}) {
	// todo
	const equip_no = fd.data.params.equip_no;
	show_loading('初始化中');
	show_nav_bar_loading();
	try {
		const data = await nodejs<any[]>('app-merchandise_shelves-find', {
			filter: {
				equip_no,
				product_up_status: '已上架'
			},
			asc: ['location_name']
		});
		console.log(data, '-------出库--------')
		if (data.length === 0) {
			const succ = await show_modal('无数据', '该门店下没有商品');
			if (succ.success) {
				// redirect_to('../output-list/output-list')
				navigate_back(1);
			}
			console.log(succ, '-----------------');
		}
		render(fd, {
			dataArray: data,
			new: true
		});
		set_local(fd, 'dataArray', data);
		set_local(fd, 'equip_no', equip_no);
		// hide_loading();
	} catch (error) {
		show_loading('读取数据失败');
		// hide_loading();
	}
	hide_loading();
	hide_nav_bar_loading();
}
